<!--
 * FCKeditor - The text editor for internet
 * Copyright (C) 2003-2005 Frederico Caldeira Knabben
 * 
 * Licensed under the terms of the GNU Lesser General Public License:
 * 		http://www.opensource.org/licenses/lgpl-license.php
 * 
 * For further information visit:
 * 		http://www.fckeditor.net/
 * 
 * "Support Open Source software. What about a donation today?"
 * 
 * File Name: LFO_SaveFileAs.html
 * 	Save file dialog window.
 * 
 * File Authors:
 * 		GreggP (greggp@pobox.com)
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Save File As</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="robots" content="noindex, nofollow" />
<script src="common.js" type="text/javascript"></script>
<script type="text/javascript">

window.onload = function()
{
	oEditor.FCKLanguageManager.TranslatePage(document) ;
	var sUrl = oConnector.ConnectorUrl +'Command=SaveFileContents&Type=File&CurrentFolder=/' ;
	document.getElementById('frmSaveFile').action = sUrl ;
	GetE('FileContents').value = FCK.GetXHTML() ;
	if ( typeof ( FCKConfig.CurrentWorkingFile ) != "undefined" )
		document.getElementById('txtUrl').value = FCKConfig.CurrentWorkingFile ;
	// Activate the "OK" button.
	window.parent.SetOkButton( true ) ;	
}
//set the url from the browser callback
function SetUrl( url )
{
	document.getElementById('txtUrl').value = url ;
	currentFolder = url ;
}


//#### The OK button was hit.
function Ok()
{
	if ( document.getElementById('txtUrl').value.length == 0 )
	{
		alert( FCKLang.LFONoFile ) ;
		return false ;
	}
	
	var sUrl = sConnUrl + 'Command=SaveFileContents&Type=File&CurrentFolder=' + document.getElementById('txtUrl').value ;
	document.getElementById('frmSaveFile').action = sUrl ;
	
	document.frmSaveFile.submit();
}

function OnSaveCompleted( iErrorNumber, fileName )
{
		switch ( iErrorNumber )
		{
			case 0 :
				window.close() ;
				SetFileName( fileName ) ;
				break ;
			case 101 :
				alert( 'Folder already exists' ) ;
				break ;
			case 102 :
				alert( 'Invalid file type' ) ;
				break ;
			case 103 :
				alert( 'You have no permissions to write this file' ) ;
				break ;
			case 104 :
				alert( 'Cannot save blank file' ) ;
				break ;
			case 105 :
				alert( 'File is too large' ) ;
				break ;				
			case 110 :
				alert( 'Unknown error creating folder' ) ;
				break ;
			default :
				alert( 'Error on your request. Error number: ' + iErrorNumber ) ;
				break ;
		}
}
//#### Initialization Code

var oEditor		= window.parent.InnerDialogLoaded() ;
var FCKLang		= oEditor.FCKLang ;
var FCKConfig	= oEditor.FCKConfig ;
var FCK			= oEditor.FCK ;

var oConnector = new Object() ;
oConnector.CurrentFolder	= '/' ;

var sConnUrl = FCKConfig.BasePath + "filemanager/browser/LFO/connectors/php/connector.php";

// Gecko has some problems when using relative URLs (not starting with slash).
if ( sConnUrl.substr(0,1) != '/' && sConnUrl.indexOf( '://' ) < 0 )
	sConnUrl = window.location.href.replace( /browser.html.*$/, '' ) + sConnUrl ;
	
sConnUrl = sConnUrl + ( sConnUrl.indexOf('?') != -1 ? '&' : '?' ) ;

</script>
</head>
<body bottomMargin="0" topMargin="0">
<form id="frmSaveFile" name="frmSaveFile" action="" target="SaveWindow" method="post" enctype="multipart/form-data" >
  <table cellSpacing="0" cellPadding="0" width="100%" border="0">
    <tr>
      <td nowrap>
        <table cellSpacing="0" cellPadding="0" width="100%" border="0">
          <tr>
            <td width="100%"><span fckLang="LFOFileName">File Name</span><br />
			<input id="FileContents" name="FileContents" type="hidden" >
			<input id="txtUrl" name="txtUrl" style="WIDTH: 100%" type="text" ></td>
            <td nowrap></td>
          </tr>
        </table><iframe id="SaveWindow" name="SaveWindow" src="../../fckblank.html" style="DISPLAY: none" ></iframe>
        </td>
    </tr>
  </table>
  <div id="divBrowseServer">
    <input type="button" value="Browse Server" fckLang="DlgBtnBrowseServer" onClick="BrowseServer();" />
  </div>
</form>
</body>
</html>
